/*
 * 
 *  This file is part of Sourceprojects.org Lycia Copyright 2010 noctarius
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 * 
 */
package org.sourceprojects.lycia;

import java.util.List;

import org.sourceprojects.lycia.internal.configuration.BasicXmlParserConfigurator;
import org.w3c.dom.Element;
import org.xml.sax.ContentHandler;

/**
 * Base class to extend the {@link LyciaConfigurator} chain in Lycia. Can be
 * used to enhance the capabilities of legal tags.
 * 
 * @author noctarius
 * @since 0.0.1
 * 
 * @param <B>
 *            Type of ContextObject to use
 */
public abstract class AbstractXmlParserConfigurator<B> extends
		BasicXmlParserConfigurator<B> {

	/**
	 * Creates a new basic {@link LyciaConfigurator} for holding all manual
	 * configurations or automatic configurations done by using FluentBuilder.
	 * 
	 * @param xmlParser
	 *            Corresponding LyciaParser
	 * @param parent
	 *            Parent LyciaConfigurator, null if no parent should be used
	 */
	public AbstractXmlParserConfigurator(final LyciaParser<B> xmlParser,
			final LyciaConfigurator<B> parent) {

		super(xmlParser, parent);

		if (xmlParser == null) {
			throw new NullPointerException("XmlParser instance cannot be null");
		}
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.sourceprojects.lycia.internal.configuration.BasicXmlParserConfigurator
	 * #addTagDefinitionParser(org.sourceprojects.lycia.TagDefinitionParser)
	 */
	@Override
	public void addTagDefinitionParser(
			final TagDefinitionParser<B> definitionParser) {
		getParentXmlParserConfigurator().addTagDefinitionParser(
				definitionParser);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.sourceprojects.lycia.internal.configuration.BasicXmlParserConfigurator
	 * #addTagDefinitionParser(java.lang.Object)
	 */
	@Override
	public void addTagDefinitionParser(final Object definitionParser) {
		getParentXmlParserConfigurator().addTagDefinitionParser(
				definitionParser);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.sourceprojects.lycia.internal.configuration.BasicXmlParserConfigurator
	 * #
	 * addTagDefinitionParsers(org.sourceprojects.lycia.TagDefinitionParser<B>[]
	 * )
	 */
	@Override
	public void addTagDefinitionParsers(
			final TagDefinitionParser<B>[] definitionParsers) {

		getParentXmlParserConfigurator().addTagDefinitionParsers(
				definitionParsers);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.sourceprojects.lycia.internal.configuration.BasicXmlParserConfigurator
	 * #addTagDefinitionParsers(java.lang.Object[])
	 */
	@Override
	public void addTagDefinitionParsers(final Object[] definitionParsers) {
		getParentXmlParserConfigurator().addTagDefinitionParsers(
				definitionParsers);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.sourceprojects.lycia.internal.configuration.BasicXmlParserConfigurator
	 * #findTagDefinitionParser(org.sourceprojects.lycia.QualifiedName,
	 * org.w3c.dom.Element)
	 */
	@Override
	public TagDefinitionParser<B> findTagDefinitionParser(
			final QualifiedName localElement, final Element element) {

		return getParentXmlParserConfigurator().findTagDefinitionParser(
				localElement, element);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.sourceprojects.lycia.internal.configuration.BasicXmlParserConfigurator
	 * #findTagDefinitionParser(java.lang.String, java.lang.String,
	 * org.w3c.dom.Element)
	 */
	@Override
	public TagDefinitionParser<B> findTagDefinitionParser(final String tagName,
			final String namespaceURI, final Element element) {

		return getParentXmlParserConfigurator().findTagDefinitionParser(
				tagName, namespaceURI, element);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.sourceprojects.lycia.internal.configuration.BasicXmlParserConfigurator
	 * #findTagDefinitionParsers(org.sourceprojects.lycia.QualifiedName,
	 * org.w3c.dom.Element)
	 */
	@Override
	public List<TagDefinitionParser<B>> findTagDefinitionParsers(
			final QualifiedName localElement, final Element element) {

		return getParentXmlParserConfigurator().findTagDefinitionParsers(
				localElement, element);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.sourceprojects.lycia.internal.configuration.BasicXmlParserConfigurator
	 * #findTagDefinitionParsers(java.lang.String, java.lang.String,
	 * org.w3c.dom.Element)
	 */
	@Override
	public List<TagDefinitionParser<B>> findTagDefinitionParsers(
			final String tagName, final String namespaceURI,
			final Element element) {

		return getParentXmlParserConfigurator().findTagDefinitionParsers(
				tagName, namespaceURI, element);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.sourceprojects.lycia.internal.configuration.BasicXmlParserConfigurator
	 * #getGenerationStrategy()
	 */
	@Override
	public GenerationStrategy getGenerationStrategy() {
		return getParentXmlParserConfigurator().getGenerationStrategy();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.sourceprojects.lycia.internal.configuration.BasicXmlParserConfigurator
	 * #getGeneratorFactory()
	 */
	@Override
	public GeneratorFactory<B> getGeneratorFactory() {
		return getParentXmlParserConfigurator().getGeneratorFactory();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.sourceprojects.lycia.internal.configuration.BasicXmlParserConfigurator
	 * #getParentXmlParserConfigurator()
	 */
	@Override
	public LyciaConfigurator<B> getParentXmlParserConfigurator() {
		return super
				.getParentXmlParserConfigurator();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.sourceprojects.lycia.internal.configuration.BasicXmlParserConfigurator
	 * #removeTagDefinitionParser(org.sourceprojects.lycia.TagDefinitionParser)
	 */
	@Override
	public void removeTagDefinitionParser(
			final TagDefinitionParser<B> definitionParser) {

		getParentXmlParserConfigurator().removeTagDefinitionParser(
				definitionParser);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.sourceprojects.lycia.internal.configuration.BasicXmlParserConfigurator
	 * #removeTagDefinitionParser(java.lang.Object)
	 */
	@Override
	public void removeTagDefinitionParser(final Object definitionParser) {
		getParentXmlParserConfigurator().removeTagDefinitionParser(
				definitionParser);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.sourceprojects.lycia.internal.configuration.BasicXmlParserConfigurator
	 * #
	 * removeTagDefinitionParsers(org.sourceprojects.lycia.TagDefinitionParser<B
	 * >[])
	 */
	@Override
	public void removeTagDefinitionParsers(
			final TagDefinitionParser<B>[] definitionParsers) {

		getParentXmlParserConfigurator().removeTagDefinitionParsers(
				definitionParsers);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.sourceprojects.lycia.internal.configuration.BasicXmlParserConfigurator
	 * #removeTagDefinitionParsers(java.lang.Object[])
	 */
	@Override
	public void removeTagDefinitionParsers(final Object[] definitionParsers) {
		getParentXmlParserConfigurator().removeTagDefinitionParsers(
				definitionParsers);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.sourceprojects.lycia.internal.configuration.BasicXmlParserConfigurator
	 * #setGenerationStrategy(org.sourceprojects.lycia.GenerationStrategy)
	 */
	@Override
	public void setGenerationStrategy(
			final GenerationStrategy generationStrategy) {
		getParentXmlParserConfigurator().setGenerationStrategy(
				generationStrategy);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.sourceprojects.lycia.internal.configuration.BasicXmlParserConfigurator
	 * #setGeneratorFactory(org.sourceprojects.lycia.GeneratorFactory)
	 */
	@Override
	public void setGeneratorFactory(final GeneratorFactory<B> generatorFactory) {
		if (getParentXmlParserConfigurator() != null) {
			getParentXmlParserConfigurator().setGeneratorFactory(
					generatorFactory);
		}
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.sourceprojects.lycia.internal.configuration.BasicXmlParserConfigurator
	 * #addContentHandler(org.xml.sax.ContentHandler)
	 */
	@Override
	public void addContentHandler(final ContentHandler contentHandler) {
		getParentXmlParserConfigurator().addContentHandler(contentHandler);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.sourceprojects.lycia.internal.configuration.BasicXmlParserConfigurator
	 * #getContentHandlers()
	 */
	@Override
	public List<ContentHandler> getContentHandlers() {
		return getParentXmlParserConfigurator().getContentHandlers();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.sourceprojects.lycia.internal.configuration.BasicXmlParserConfigurator
	 * #removeContentHandler(org.xml.sax.ContentHandler)
	 */
	@Override
	public void removeContentHandler(final ContentHandler contentHandler) {
		getParentXmlParserConfigurator().removeContentHandler(contentHandler);
	}

}
